package com.yurun.controller;

import com.yurun.entity.Business;
import com.yurun.model.vo.PageResult;
import com.yurun.model.vo.Result;
import com.yurun.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class BusinessController {
    @Autowired
    BusinessService businessService;
    /**
     * @Description: 前台-业务信息列表
     * @Param: pageNum
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @GetMapping("/businesslist")
    public Result getBusinessList(@RequestParam Integer pageNum){
        PageResult<Business> object=businessService.getBusinessList(pageNum);
        return Result.ok("业务",object);
    }
    /**
     * @Description: 前台-通过分类-业务信息列表
     * @Param: bcategoryId
     * @Param pageNum
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @GetMapping("/businesslistbycategory")
    public Result getBusinessListByCategoryId(@RequestParam Integer bcategoryId,
                                              @RequestParam Integer pageNum){
        PageResult<Business> object=businessService.getBusinessListByCategoryId(bcategoryId,pageNum);
        return Result.ok("分类下的业务",object);
    }
    /**
     * @Description: 前台-通过名称搜索-业务详细信息
     * @Param: name
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @GetMapping("/business")
    public Result getBusinessByName(@RequestParam String name){
        Business object=businessService.getBusinessByName(name);
        return Result.ok("业务详情",object);
    }
}
